package com.usian.service.impl;

import com.alibaba.nacos.common.utils.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.usian.common.dto.MemberTestHistoryDTO;
import com.usian.common.model.member.MemberTestHistory;
import com.usian.mapper.MemberTestHistoryMapper;
import com.usian.service.MemberTestHistoryService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @projectName: 2210A-project1
 * @package: com.usian.service.impl
 * @className: MemberTestHistoryServiceImpl
 * @author: 莫洪维
 * @email: 1204315800@qq.com
 * @description: TODO
 * @date: 2023/9/4 16:00
 */
@Service
public class MemberTestHistoryServiceImpl extends ServiceImpl<MemberTestHistoryMapper, MemberTestHistory> implements MemberTestHistoryService {
    @Override
    public PageInfo<MemberTestHistory> findByMemberId(MemberTestHistoryDTO memberTestHistoryDTO) {
        //调用方法进行查询
        PageHelper.startPage(memberTestHistoryDTO.getPageNum(),memberTestHistoryDTO.getPageSize());
        QueryWrapper<MemberTestHistory> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(MemberTestHistory::getMemberId,memberTestHistoryDTO.getMemberId());
        if (StringUtils.isNotBlank(memberTestHistoryDTO.getPaperName())){
            wrapper.lambda().like(MemberTestHistory::getPaperName,memberTestHistoryDTO.getPaperName());
        }
        List<MemberTestHistory> list = this.baseMapper.selectList(wrapper);
        //创建分页实体类
        PageInfo<MemberTestHistory> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
